﻿@{
    ViewBag.Title = "SimpleString";
}

<h2>SimpleString</h2>

<table class="data">
    <thead>
        <tr>
            <td>Press button</td><td>Result</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><button id="btnFetchJSON">Fetch Json</button></td><td id="result">Nothing yet!</td>
        </tr>
    </tbody>
</table>

@section scripts{
    <script type="text/javascript">
        $("#btnFetchJSON").click(function() {
            $.ajax({
                type: "POST",
                url: "@Url.Action("SimpleStringResult")",
                data: "inparameter=John",
                success: function(msg) {
                    var jSONObj = jQuery.parseJSON(msg);
                    $("#result").html(jSONObj.widget.window.name);
                },
                error: function(errorMsg) {
                    alert('Uncaught Error.\n' + errorMsg.responseText);
                }
            });
        });
    </script>
    }